package objects 
{
	import flash.geom.Point;
	import objects.Effect;
	import starling.core.Starling;
	import starling.display.MovieClip;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.extensions.PDParticleSystem;
	/**
	 * ...
	 * @author Vượng
	 */
	public class Star_Effect extends Effect
	{
		public var m_par:PDParticleSystem;
		public function Star_Effect(_sprite:Sprite,_par : PDParticleSystem, _pos : Point,_coolDown:int) 
		{
			super(_sprite, _pos);
			this.addEventListener(Event.ADDED_TO_STAGE, init);
			m_par = _par;
			Starling.juggler.add(m_par);
			this.addChild(m_par);
			m_par.x = _pos.x;
			m_par.y = _pos.y;
			this.m_coolDown = _coolDown;
			_sprite.addChild(this);
			m_par.start();
		}
		
		private function init(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
		}

		override public function update(dt:Number):void
		{
			if (m_coolDown > 1)
			{
				m_coolDown -= 1;
			}
			if (m_coolDown == 1)
			{
				m_par.stop();
				if (m_par.numParticles == 0)
				{
					m_coolDown = 0;
				}
			}

		}
		public function CollisionWithArray ( _enemy : Array, dt : Number) :void
		{

		}
	}

}